package com.suredy.app.porject.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.suredy.app.porject.constants.FlowStatus;
import com.suredy.core.model.BaseModel;
import com.suredy.security.entity.UserEntity;

/**
 * 合同流转用户记录
 * 
 * @author VIVID.G
 * @since 2015-12-23
 * @version v0.1
 */
@Entity
@Table(name = "tb_flow_contract2user", uniqueConstraints = {@UniqueConstraint(columnNames = {"contract_id", "user_id", "status"})})
public class FlowOfContract2User extends BaseModel {

	private static final long serialVersionUID = 1L;

	/* 合同信息 */
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "contract_id", nullable = false)
	private Contract contract;

	/* 投标信息 */
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id")
	private UserEntity user;

	/* 用户类型 */
	@Column(name = "status", nullable = false, length = 100)
	@Enumerated(EnumType.STRING)
	private FlowStatus status;

	/* 是否在办 */
	@Column(nullable = false, columnDefinition = "int default 0")
	private Boolean active;

	/* 流程时间 */
	@Column(nullable = false)
	private Date time;

	public Contract getContract() {
		return contract;
	}

	public void setContract(Contract contract) {
		this.contract = contract;
	}

	public UserEntity getUser() {
		return user;
	}

	public void setUser(UserEntity user) {
		this.user = user;
	}

	public FlowStatus getStatus() {
		return status;
	}

	public void setStatus(FlowStatus status) {
		this.status = status;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

}
